if(NOT OPENMP_TEST_COMPILER_ID STREQUAL "Clang")
  # Silently return, no need to annoy the user.
  return()
endif()

set(deps omptarget omp)
if(LIBOMPTARGET_NVPTX_ENABLE_BCLIB)
  set(deps ${deps} omptarget-nvptx-bc)
endif()

# Run with only one thread to only launch one application to the GPU at a time.
add_openmp_testsuite(check-libomptarget-nvptx
    "Running libomptarget-nvptx tests" ${CMAKE_CURRENT_BINARY_DIR}
    EXCLUDE_FROM_CHECK_ALL
    DEPENDS ${deps} ARGS -j1)

set(LIBOMPTARGET_NVPTX_TEST_FLAGS "" CACHE STRING
    "Extra compiler flags to send to the test compiler.")
set(LIBOMPTARGET_NVPTX_TEST_OPENMP_FLAGS
    "-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda" CACHE STRING
    "OpenMP compiler flags to use for testing libomptarget-nvptx.")

# Configure the lit.site.cfg.in file
set(AUTO_GEN_COMMENT "## Autogenerated by libomptarget-nvptx configuration.\n# Do not edit!")
configure_file(lit.site.cfg.in lit.site.cfg @ONLY)
